@extends('admin._layouts.default')

<script language="javascript" type="text/javascript" src="{{ URL::asset('ueditor/ueditor.config.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ueditor/ueditor.config.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ueditor/ueditor.all.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ueditor/lang/zh-cn/zh-cn.js') }}"></script>
@section('main')


      <div class="row-fluid ">
        <div class="span12 box gradient ">
      <div class="title">
            <div class="row-fluid">
                <h3><a class="btn btn-mini pull-right mg5"><i class="fa fa-hand-o-left"></i> 返回</a>
                  <i class="fa fa-cube"></i> 发布商品
                </h3>
            </div>
        </div><!-- End .title -->
        <div class="content">
            {{ Form::model($commodity, array('method' => 'put', 'route' => array('admin.commodities.update', $commodity->id),'files'=>true,'id'=>'commodities','class'=>'bs-docs-example form-horizontal')) }}
                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="text">宝贝名称</label>
                    <div class="controls span6">
                      <div class="input-prepend row-fluid">
                        <span class="add-on prepend "><i class="fa fa-cube "></i></span>
                        <input class="row-fluid" id="cloth2" value="{{ $commodity->name }}" name="name" required  size="50" type="text" >
                      </div>
                    </div>
                  </div>
                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="text">价格体系</label>
                    <div class="controls span2">
                      <div class="input-prepend row-fluid">
                        <span class="add-on prepend "><i class="fa fa-user "></i></span>
                        <input class="row-fluid" id="author" value="{{ $commodity->member_price }}" name="member_price" required  size="50" type="text" placeholder="会员价">
                      </div>
                    </div>
                    <div class="controls span2">
                      <div class="input-prepend row-fluid">
                        <span class="add-on prepend "><i class="fa fa-credit-card "></i></span>
                        <input class="row-fluid" id="author" value="{{ $commodity->member_points }}" name="member_points" required  size="50" type="text" placeholder="积分">
                      </div>
                    </div>
                    <div class="controls span2">
                      <div class="input-prepend row-fluid">
                        <span class="add-on prepend "><i class="fa fa-bank "></i></span>
                        <input class="row-fluid" id="author" value="{{ $commodity->public_price }}" name="public_price" required  size="50" type="text" placeholder="市场价">
                      </div>
                    </div>
                  </div>
                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="text">商品类型</label>
                    <div class="controls span4">
                      <label class="inline radio">
                      <input type="radio" name="type" @if($commodity->type == 1) checked @endif value="1"/> 独立商品 </label>
                      <label class="inline radio">
                      <input type="radio" name="type" @if($commodity->type == 2) checked @endif value="2"/> 滤芯 </label>
                      <label class="inline radio">
                      <input type="radio" name="type" @if($commodity->type == 3) checked @endif value="3"/> 服务 </label>
                      <label class="inline radio">
                      <input type="radio" name="type" @if($commodity->type == 4) checked @endif value="4"/> 代金券 </label>
                    </div>
                  </div>

                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="text">商品板块</label>
                    <div class="controls span4">:
                        @foreach($tabs as $key => $tab)
                      <label class="inline radio">
                      <input type="checkbox" name="tab[]" {{ $checks[$key] }} value="{{ $key }}"/> {{ $tab }} </label>
                      @endforeach
                    </div>
                  </div>
                  <div class="form-row control-group row-fluid">
                      <label class="control-label span3" for="text">有效期(月)</label>
                      <div class="controls span1">
                        <div class="input-prepend row-fluid">
                          <span class="add-on prepend "><i class="fa fa-cube "></i></span>
                          <input class="row-fluid" id="cloth2" name="life"  value="{{ $commodity->life }}" size="" type="text" >(月)
                        </div>
                      </div>
                    </div>
                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="search-input">封面头图 <span class="help-block">建议尺寸：900像素 * 500像素</span></label>
                    <div class="controls span7">
                      <div class="input-append row-fluid">
                        <input type="file" name="cover" class="spa1n6 fileinput" id="search-input">
                      </div>
                    </div>
                  </div>

                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="text">宝贝摘要</label>
                    <div class="controls span6">
                      <textarea id="text" rows="2" name="dec" class="row-fluid">{{ $commodity->dec }}</textarea>
                      <div id="bottom">
                        <span id="chars">100</span> 字剩余
                      </div>
                    </div>
                  </div>
                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="editor1">宝贝描述
                    </label>
                    <div class="controls span6">
                        <script id="editor" type="text/plain" style="height:500px;">{{ $commodity->content }}</script>
                      {{--<textarea name="content" id="editor1" class="row-fluid" rows="15"></textarea>--}}
                    </div>
                  </div>
                 <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="text">库存</label>
                    <div class="controls span2">
                      <div class="input-prepend row-fluid">
                        <span class="add-on prepend "><i class="fa fa-cubes "></i></span>
                        <input class="row-fluid" name="number" value="{{ $commodity->number }}" id="cloth2" required  size="50" type="text" >
                      </div>
                    </div>
                  </div>

                  <div class="form-actions row-fluid">
                    <div class="span10 offset3">
                      <button type="submit" class="btn btn-large btn-info"><i class="fa fa-save"></i> 立即保存</button>
                      <button type="button" class="btn btn-large"><i class="fa fa-hand-o-left"></i> 取消</button>
                    </div>
                  </div>
               {{ Form::close() }}




            </div>
        </div>
        <!-- End box -->
      </div>


@stop

@section('script')
<script language="javascript" type="text/javascript" src="{{ URL::asset('web/js/plugins/jquery.peity.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('web/js/plugins/jquery.uniform.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('web/js/plugins/chosen/chosen/chosen.jquery.min.js') }}"></script>

<script language="javascript" type="text/javascript" src="{{ URL::asset('web/js/plugins/flot/jquery.flot.js') }}"></script>



<script src="{{ URL::asset('web/js/scripts.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('web/js/jnavigate.jquery.min.js') }}"></script>
<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');

</script>
<script type="text/javascript">

        var maxstrlen = 100;
        function Q(s) { return document.getElementById(s); }

        function checkWord(c) {
            len = maxstrlen;
            var str = c.value;
            myLen = getStrleng(str);
            var wck = Q("wordCheck");

            if (myLen > len * 2) {
                c.value = str.substring(0, i + 1);
            }
            else {
                wck.innerHTML = Math.floor((len * 2 - myLen) / 2);
            }
        }

        function getStrleng(str) {
            myLen = 0;
            i = 0;
            for (; (i < str.length) && (myLen <= maxstrlen * 2); i++) {
                if (str.charCodeAt(i) > 0 && str.charCodeAt(i) < 128)
                    myLen++;
                else
                    myLen += 2;
            }
            return myLen;
        }
        function fabu(){
            $('#pages').submit();
        }
</script>
@stop
